﻿using System;
using System.Collections.Generic;
using System.Text;
using Csla.Data;

namespace MinaspetroLibrary.CurriculoPack
{
    [Serializable()]
    public class CurriculoChildInfo : Csla.ReadOnlyBase<CurriculoChildInfo>
    {
        #region Business Properties and Methods

        //declare members

        private Guid _id = Guid.NewGuid();

        private String _nome = String.Empty;

        private String _senha = String.Empty;
        
        private DateTime _dataNascimento = DateTime.Now;
        
        private Guid _idEndereco = Guid.NewGuid();
        
        private Guid _idContato = Guid.NewGuid();
        
        private Guid _idAreaInteresse = Guid.NewGuid();
        
        private String _objetivos = String.Empty;
        
        private String _qualificacoes = String.Empty;
        
        private String _observacoes = String.Empty;
        
        private DateTime _dataCadastro = DateTime.Now;

        [System.ComponentModel.DataObjectField(true, true)]
        public Guid Id
        {
            get
            {
                return _id;
            }
        }

        
		public String Nome
        {
            get
            {
                return _nome;
            }
        }

        public String Senha
        {
            get
            {
                return _senha;
            }
        }

        public DateTime DataNascimento
        {
            get
            {
                return _dataNascimento;
            }
        }

        public Guid IdEndereco
        {
            get
            {
                return _idEndereco;
            }
        }

        public Guid IdAreaInteresse
        {
            get
            {
                return _idAreaInteresse;
            }
        }



        public Guid IdContato
        {
            get
            {
                return _idContato;
            }
        }

        public String Objetivos
        {
            get
            {
                return _objetivos;
            }
        }

        public String Qualificacoes
        {
            get
            {
                return _qualificacoes;
            }
        }

        public String Observacoes
        {
            get
            {
                return _observacoes;
            }
        }

        public DateTime DataCadastro
        {
            get
            {
                return _dataCadastro;
            }
        }


        protected override object GetIdValue()
        {
            return _id.ToString();
        }

        #endregion //Business Properties and Methods

        #region Authorization Rules
        protected override void AddAuthorizationRules()
        {
            //TODO: Define authorization rules in CurriculoChildInfo

        }

        #endregion //Authorization Rules

        #region Factory Methods
        internal static CurriculoChildInfo GetCurriculoChildInfo(SafeDataReader dr)
        {
            return new CurriculoChildInfo(dr);
        }

        private CurriculoChildInfo(SafeDataReader dr)
        {
            Fetch(dr);
        }
        #endregion //Factory Methods

        #region Data Access

        #region Data Access - Fetch
        private void Fetch(SafeDataReader dr)
        {
            FetchObject(dr);

            //load child object(s)
            FetchChildren(dr);

        }

        private void FetchObject(SafeDataReader dr)
        {
            _id = new Guid(dr["Id"].ToString());
            _nome = dr.GetString("Nome");
            _senha = dr.GetString("Senha");
            _dataNascimento = dr.GetDateTime("DataNascimento");
            _idEndereco = new Guid(dr["IdEndereco"].ToString());
            _idContato = new Guid(dr["IdContato"].ToString());
            _idAreaInteresse = new Guid(dr["IdAreaInteresse"].ToString());
            _objetivos = dr.GetString("Objetivos");
            _qualificacoes = dr.GetString("Qualificacoes");
            _observacoes = dr.GetString("Observacoes");
            _dataCadastro = dr.GetDateTime("DataCadastro");
        }

        private void FetchChildren(SafeDataReader dr)
        {
        }
        #endregion //Data Access - Fetch
        #endregion //Data Access
    }
}
